
//
// Store all of the Broadcast Navigation data for a particular satellite 
//

// Only create a new class when a satelite is observed for the first time
public class NavDataGPS {

    /**
      * PRN / EPOCH / SV CLK
      * prn satellite PRN number
      * toc Time of Clock        (seconds)
      * a0  clock bias           (seconds)
      * a1  clock drift          (sec/sec)
      * a2  clock drift rate     (sec/sec2)
    */
    private int prn;
    private double toc; // currntly in MS
    private double a0;
    private double a1;
    private double a2;

    /**
      * First Frame Variable from Ephemeris
      * IODE Issue Date of Ephemeris
      * Crs                      (meters)
      * Delta n                  (radians/sec)
      *   - variation of mean angular velocity
      * m0 mean anomaly          (radians)
    */
    private double IODE;
    private double Crs;
    private double dN;
    private double m0;

    /**
      * Second Frame Variables
      * Cuc                         (radians)
      * ecc (eccentricity)          
      * Cus                         (radians)
      * sqrtA Semi-major axis       (sqrt(m))
    */
    private double Cuc;
    private double ecc;
    private double Cus;
    private double sqrtA;

    /** 
      *  Third Frame Variables
      *   Toe Time of Ephemeris     (sec of GPS Week)
      *       -This is the reference epoch for the message block
      *   Cic                       (radians) 
      *   OMEGA (right ascension)   (radians)
      *   CIS                       (radians)
    */
    private double Toe;
    private double Cic;
    private double OMEGA;
    private double CIS;

    /**
      * Fourth Frame variables
      * i0 (inclination)                   (radians)
      * Crc                                (meters)
      * omega ( argument of perigee )      (radians)
      * OMEGADot (rate right ascension)    (radians/sec)
    */
    private double i0;
    private double Crc;
    private double omega;
    private double OMEGADot;

    /**
      * Fifth Frame Variables
      * idot (rate of inclination)     (radians/sec)
      * l2channel (codes on l2 channel)
      * gpswk (continuous number, not mod(1024))
      * l2pFlag (data flag)
    */
    private double idot;
    private double l2channel;
    private double gpswk;
    private double l2pFlag;

    /**
      * Sixth Frame Variables
      * sva (SV accuracy)                (meters)
      * svh (SV Health)                  
      * tgd                              (seconds)
      * iodc (Issue of Data, Clock)  
    */
    private double sva;
    private double svh;
    private double tgd;
    private double iodc;

    /**
      * Seventh Frame Variables
      * zcount (Transmission time of message)
      * Fit Interval                           (hours)
      *  (see ICD-GPS-200, 20.3.4.4)
      *  Zero if not known
      * spare1
      * spare2
    */
    private double zcount;
    private double fit = 0.0;
    private double spare1 = 0.0;
    private double spare2 = 0.0;

    NavDataGPS (int PRN, double time) {
        prn = PRN;
        toc = time;
    //    System.out.println("Created NavDataGPS for :"+prn+" "+time);
    }

    public void firstLine(double cB, double cD, double cDR) {
        a0 = cB;
        a1 = cD;
        a2 = cDR;
    }

    public int prn() { return prn;}
    public double toc() { return toc;}
    public double a0() { return a0;} 
    public double a1() { return a1;}
    public double a2() { return a2;}

    public void setIODE( double val ) { IODE = val; }
    public void setCrs(double val ) { Crs = val; }
    public void setdN(double val) { dN = val;}
    public void setm0(double val) { m0 = val;}
    public double IODE() { return IODE; }
    public double Crs() { return Crs; }
    public double dN() { return dN;}
    public double m0() { return m0; }

    public void setCuc(double val) { Cuc = val;}
    public void setecc(double val) { ecc = val;}
    public void setCus(double val) { Cus = val;}
    public void setsqrtA(double val) { sqrtA = val;}
    public double Cuc() {return Cuc;}
    public double ecc() {return ecc;}
    public double Cus() {return Cus;}
    public double sqrtA() {return sqrtA;}

    public void setToe(double val) { Toe = val;}
    public void setCic(double val) { Cic= val;}
    public void setOMEGA(double val) { OMEGA = val;}
    public void setCIS(double val) { CIS = val;}
    public double Toe() {return Toe;}
    public double Cic() {return Cic;}
    public double OMEGA() {return OMEGA; }
    public double CIS() {return CIS;}

    public void seti0(double val) { i0 = val;}
    public void setCrc(double val) { Crc= val;}
    public void setomega(double val) { omega = val;}
    public void setOMEGADot(double val) { OMEGADot = val;}
    public double i0() {return i0;}
    public double Crc() {return Crc;}
    public double omega() {return omega; }
    public double OMEGADot() {return OMEGADot;}

    public void setidot(double val) { idot = val;}
    public void setl2channel(double val) { l2channel = val;}
    public void setgpswk(double val) { gpswk = val;}
    public void setl2pFlag(double val) { l2pFlag = val;}
    public double idot() {return idot;}
    public double l2channel() {return l2channel;}
    public double gpswk() {return gpswk; }
    public double l2pFlag() {return l2pFlag;}

    public void setsva(double val) { sva = val;}
    public void setsvh(double val) { svh = val;}
    public void settgd(double val) { tgd = val;}
    public void setiodc(double val) { iodc = val;}
    public double sva() {return sva;}
    public double svh() {return svh;}
    public double tgd() {return tgd; }
    public double iodc() {return iodc;}

    public void setzcount(double val) { zcount = val;}
    public void setfit(double val) { fit = val;}
    public void setspare1(double val) { spare1 = val;}
    public void setspare2(double val) { spare2 = val;}
    public double zcount() { return zcount;}
    public double fit() { return fit;}
    public double spare1() {return spare1;}
    public double spare2() {return spare2;}

    public void printRecord() {
        System.out.println();
        System.out.println("Printing Nav record for Satellite: "+prn); 
        System.out.println();
        System.out.println(" TOC       : "+toc); // currntly in MS
        System.out.println(" a0        : "+a0);
        System.out.println(" a1        : "+a1);
        System.out.println(" a2        : "+a2);
    
        System.out.println();
        System.out.println(" IODE      : "+IODE); 
        System.out.println(" Crs       : "+Crs); 
        System.out.println(" dN        : "+dN);
        System.out.println(" m0        : "+m0); 

        System.out.println();
        System.out.println(" Cuc       : "+Cuc);
        System.out.println(" ecc       : "+ecc);
        System.out.println(" Cus       : "+Cus);
        System.out.println(" sqrtA     : "+sqrtA);

        System.out.println();
        System.out.println(" Toe       : "+Toe);
        System.out.println(" Cic       : "+Cic);
        System.out.println(" OMEGA     : "+OMEGA);
        System.out.println(" CIS       : "+CIS);

        System.out.println();
        System.out.println(" i0        : "+i0);
        System.out.println(" Crc       : "+Crc);
        System.out.println(" omega     : "+omega); 
        System.out.println(" OMEGADot  : "+OMEGADot);

        System.out.println();
        System.out.println(" idot      : "+idot);
        System.out.println(" l2channel : "+l2channel);
        System.out.println(" gpswk     : "+gpswk); 
        System.out.println(" l2pFlag   : "+l2pFlag);

        System.out.println();
        System.out.println(" sva       : "+sva);
        System.out.println(" svh       : "+svh);
        System.out.println(" tgd       : "+tgd); 
        System.out.println(" iodc      : "+iodc);

        System.out.println();
        System.out.println(" zcount    : "+zcount);
        System.out.println(" fit       : "+fit);
        System.out.println(" spare1    : "+spare1);
        System.out.println(" spare2    : "+spare2);
        System.out.println();
        System.out.println();
        
    }
}
